<?php
/* 
* @Title:  [商品类型控制器]
* @Author: {chenlei} [chenleib5@126.com]
* @Date:   2014-04-04 17:48:34
* @Last Modified by:   Administrator
* @Last Modified time: 2014-04-11 21:38:43
* @Copyright:  [hn7m.com]
*/
class TypeControl extends CommonControl{
	private $typeModel=NULL;
	private $attrModel=NULL;
	private $typeViewModel=NULL;
	/**
	 * [__init 自动加载Type模型类]
	 * @return [type] [description]
	 */
	public function __init(){
		parent::__init();
		$this->typeModel=K('Type');
		$this->attrModel=K('Attr');
		$this->typeViewModel=K('typeView');
	}

	/**
	 * [index 默认显示类型列表]
	 * @return [type] [description]
	 */
	public function index(){

		$type=$this->typeModel->get_data();
		$this->assign('type',$type);
		$this->display();
	}

	/**
	 * [add_type 添加类型]
	 */
	public function add_type(){
		if(IS_POST){
			//自动验证类型表数据
			if(!$this->typeModel->create()){
				$this->error($this->typeModel->error);
			}
			//插入类型表
			$tid=$this->typeModel->add_type_data();
			if(!$tid){
				$this->error($this->typeModel->error);
			};
			$this->success('恭喜您,类型添加成功!',U('index'));
		}
		$this->display();
	}
}
?>